﻿function XRight() {
	if (el("body").className == "XRight") {
		el("body").className = "";
	} else {
		el("body").className = "XRight";
	}
}
function addSub(element) {
	if (element.parentElement.id=="cen"){
		var eli = document.createElement("input");
		eli.setAttribute("type", "number");
		el("#rig").children[1].appendChild(element);
		element.insertBefore(eli, element.children[3]);
	} else {
		if (el("#cen").children[0] == undefined) {
			el("#cen").appendChild(element);
		} else {
			el("#cen").insertBefore(element, el("#cen").children[0]);
		}
		element.removeChild(element.children[3]);
	}
}
function showDetail(element) {
	var url = element.getAttribute("data-id");
	url = urlHost+"Order/Detail?id=" + url;
	openPopup("#detail", url);
}
window.addEventListener("load", function () {
	var elsi=els("#cen.home>div");
	for (i=0;i<elsi.length;i++) {
		var element = document.createElement("div");
		element.setAttribute("onclick", "addSub(this.parentElement);");
		elsi[i].insertBefore(element, elsi[i].children[2]);
		element = document.createElement("div");
		element.setAttribute("onclick", "showDetail(this.parentElement);");
		elsi[i].insertBefore(element, elsi[i].children[4]);
		elsi[i].className = "product";
	}
});